package com.alu.sg.allstart.utils;


import com.alu.sg.allstart.allstar.bean.NamesData;

import java.util.Comparator;

/**
 * Created by Alu on 2017/5/3.
 * 版本：V1.0
 *
 * sort with pys
 */

public class LetterComparator implements Comparator<NamesData> {

    @Override
    public int compare(NamesData l, NamesData r) {
        if (l == null || r == null) {
            return 0;
        }

        String lhsSortLetters = l.getPys().substring(0, 1).toUpperCase();
        String rhsSortLetters = r.getPys().substring(0, 1).toUpperCase();
//        if (lhsSortLetters == null || rhsSortLetters == null) {
//            return 0;
//        }
        return lhsSortLetters.compareTo(rhsSortLetters);
    }
}